package cn.sciento.boot.tenant.hiam.api.controller.v1;

import cn.sciento.swagger.annotation.Permission;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import cn.sciento.boot.tenant.dto.TenantInitConfigDTO;
import cn.sciento.boot.tenant.dto.TenantInitLogDTO;
import cn.sciento.boot.tenant.hiam.app.service.HiamTenantInitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("hiamTenantInitProcessController.v1")
@RequestMapping({"/hiam/v1/tenant-init"})
public class HiamTenantInitProcessController {
  @Autowired
  private HiamTenantInitService hiamTenantInitService;
  
  @ApiOperation("租户初始化处理器注册")
  @Permission(permissionWithin = true)
  @PostMapping({"/register"})
  public ResponseEntity<TenantInitConfigDTO> register(@ApiParam("租户初始化处理器配置") @RequestBody TenantInitConfigDTO tenantInitConfigDTO) {
    return ResponseEntity.ok(this.hiamTenantInitService.register(tenantInitConfigDTO));
  }
  
  @ApiOperation("租户初始化处理器日志")
  @Permission(permissionWithin = true)
  @PostMapping({"/log"})
  public ResponseEntity<TenantInitLogDTO> log(@ApiParam("租户初始化处理器日志") @RequestBody TenantInitLogDTO tenantInitLogDTO) {
    return ResponseEntity.ok(this.hiamTenantInitService.log(tenantInitLogDTO));
  }
}
